<template>
	<view>
		<uni-section title="员工信息" type="line" style="color: #409EFF;"></uni-section>
		<text class="tips" v-if="employee.length <= 0">无员工信息</text>
		<uni-grid :column="5" :showBorder="false" :square="false" style="background-color: #e3e3e3;">
		    <uni-grid-item v-for="item in employee" :key="item.id">
				<view>
					<img class="avatar" :src="item.avatar == '' ? defaultAvatar : item.avatar" />
					<text class="text">{{ item.realName == "" || item.reamName == null ? item.nickName : item.realName }}</text>
				</view>
		    </uni-grid-item>
		</uni-grid>
		<uni-section title="团队基本信息" type="line" />
		<view style="margin-top: 10rpx;width:95%">
			<uni-list>
				<uni-list-item title="团队名称" :rightText="team.name" />
				<uni-list-item title="管理员" :rightText="user.nickName" />
				<uni-list-item title="创建日期" :rightText="team.createTime" />
				<uni-list-item title="是否开启流程控制" :rightText="team.openControl == 'CLOSE' ? '否' : '是'" />
				<uni-list-item title="审核总步骤" :rightText="team.openControl == 'CLOSE' ? '无' : team.auditLevel" />
				<uni-list-item title="团队简介"/>
				<view style="width: 95%;">
					<text style="font-size: 14px; color: #3b4144;margin-left: 30rpx;">{{ team.note }}</text>
				</view>
			</uni-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				team: {},
				employee: [],
				user: {},
				defaultAvatar: '/static/defaultAvatar.png',
			}
		},
		onLoad(ev) {
			this.getTeamById(ev.id);
			this.getEmployee(ev.id);
			this.user = this.$dry.get("user");
		},
		onShow(){
		},
		methods: {
			getTeamById(id){
				var token = this.$dry.getToken();
				if(token){
				    var data = this.$request.run("getTeamById",token);
				    uni.request({
				    	url: data.url,
				    	method: data.method,
				    	header: data.header,
				    	data: {
							"id": id
						},
				    	success: data => {
				    		this.team = data.data;
						}
					})
				}
			},
			getEmployee(id) {
				var token = this.$dry.getToken();
				if(token){
				    var data = this.$request.run("listEmployeeByConditions",token);
				    uni.request({
				    	url: data.url,
						method: data.method,
						header: data.header,
				    	data: {
							"teamId": id,
							"employeeStatus": 'TEAM'
						},
				    	success: data => {
				    		this.employee = data.data;
				    	},
				    	fail: (data, code) => {
				    		console.log('fail' + JSON.stringify(data));
				    	}
				    })
				}
			},
		}
	}
</script>

<style>
	.avatar{
	    width: 54px;
	    height: 54px;
	    margin: 10px;
	    display: block;
	    border-radius: 10rpx;
	}
	.text{
		text-align: center;
		display: block;
		font-size: 12px;
	}
	.tips{
		padding:10rpx 20rpx;
		text-align: left;
		font-size: 24rpx;
		color: #0077AA;
	}
</style>
